﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using WebApi.Core.Model.ResponseModels;

namespace WebApi.Core.IRepository.Base
{
    /// <summary>
    /// 基类接口，其它接口继承该接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IBaseRepository<TEntity> where TEntity:class
    {

        Task<int> InsertAsync(TEntity model);

        Task<List<int>> InsertBatchAsync(List<TEntity> model);

        Task<bool> UpdateAsync(TEntity entity);
        Task<bool> UpdateAsync(TEntity entity, Expression<Func<TEntity, bool>> where, bool ignoreNull = true);
        Task<bool> UpdateAsync(TEntity entity, Expression<Func<TEntity, Object>>? columns = null, Expression<Func<TEntity, bool>>? where = null, bool ignoreNull = true);

        Task<bool> DeleteByIdAsync(object id);
        Task<bool> DeleteByIdsAsync(object[] ids);

        Task<TEntity> QueryById(object objId);
        Task<TEntity> QueryAsync(Expression<Func<TEntity, bool>> where);

        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, object>> orderBy, bool isAsc = true);

        Task<PageResult<TEntity>> QueryPageAsync(Expression<Func<TEntity, bool>> where, int pageIndex, int pageSize, Expression<Func<TEntity, object>> orderBy, bool isAsc = true);

        Task<bool> ExistAsync(Expression<Func<TEntity, bool>> where);

        Task<int> CountAsync(Expression<Func<TEntity, bool>> where);

    }
}
